﻿<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
    xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>
		  Attach Files to Outlook E-Mail Items
	  </Title>
    </Header>
    <Snippet>
      <Code Language="CSharp">
        <![CDATA[
		private void ThisApplication_Startup(object sender, System.EventArgs e)
		{
			AddAttachment();
		}

		private void AddAttachment()
		{
			Outlook.MailItem mail =
				this.CreateItem
				(Outlook.OlItemType.olMailItem)
				as Outlook.MailItem;

			mail.Subject = "An attachment for you!";

			OpenFileDialog attachment = new OpenFileDialog();

			attachment.Title = "Select a file to send";
			attachment.ShowDialog();

			if (attachment.FileName.Length > 0)
			{
				mail.Attachments.Add(
					attachment.FileName,
					Outlook.OlAttachmentType.olByValue,
					1,
					attachment.FileName);
				mail.Recipients.Add("Armando Pinto ");
				((Outlook._MailItem)mail).Send();
			}
		}

		]]>
	</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>